package com.xm9m.ibczy.mytest.alimama.mobile.demo;

import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup;

import com.alimama.mobile.sdk.MmuSDK;
import com.alimama.mobile.sdk.config.HandleProperties;
import com.alimama.mobile.sdk.config.MmuSDKFactory;
import com.xm9m.ibczy.mytest.R;

public class HandleActivity extends BaseActivity {
	private MmuSDK mmuSDK;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.inset);
		setTitle("推广墙");

		ViewGroup nat = (ViewGroup) findViewById(R.id.nat);
		String slotId = "60933";
//		String slotId = "50862";
//		String slotId = "54351";
		setupAlimama(nat, slotId);

		// ViewGroup h5 = (ViewGroup) findViewById(R.id.h5);
		// slotId = "60934";
		// setupAlimama(h5,slotId);
		//
		// ViewGroup app = (ViewGroup) findViewById(R.id.app);
		// slotId = "54351";
		// setupAlimama(app,slotId);

	}

	private void setupAlimama(ViewGroup nat, String slotId) {
		mmuSDK = MmuSDKFactory.getMmuSDK();
		mmuSDK.init(getApplication());
		mmuSDK.accountServiceInit(this);

		ViewGroup handleContainer = (ViewGroup) getLayoutInflater().inflate(
				R.layout.handle_layout, nat, false);
		HandleProperties properties = new HandleProperties(slotId, nat);
		// .setHandleContainer(handleContainer);
		mmuSDK.attach(properties);
		// try{
		// Configuration config = new Configuration(slotId,"7");
		// new MmuSDK(this).inset(nat,config);
		// }catch(Exception e){
		// Log.e("InsetActivity", "", e);
		// }
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (!mmuSDK.accountServiceHandleResult(requestCode, resultCode, data,this)) {
			super.onActivityResult(requestCode, resultCode, data);
		}
	}
	
}
